package com.leantech.android.browser.browser

import android.graphics.Bitmap
import androidx.fragment.app.Fragment
import kotlinx.coroutines.flow.Flow

interface BrowserTab {

    val backStackFlow: Flow<List<BackStackItem>>

    val backStateFlow: Flow<Boolean>

    val forwardStateFlow: Flow<Boolean>

    val favoriteStateFlow: Flow<Boolean>

    val currentUrlFlow: Flow<Pair<String, String>>

    fun getWebViewController(): WebViewController?

    fun loadUrl(url: String, clearHistory: Boolean)

    fun getFragment(): Fragment

    fun getTitle(): String?

    fun getFavicon(): Bitmap?

    fun requestCapture(callback: (Bitmap?) -> Unit)

    fun getPreview(): Bitmap?

    fun toggleFavorite()

    fun webViewVisible(): Boolean

    fun home()

    fun back()

    fun forward()

    fun reload()

    fun pause()

    fun resume()

    fun destroy()

    suspend fun getRawText(): String?

    fun enableReaderMode(enable: Boolean)

    sealed interface BackStackItem {
        data object Home : BackStackItem

        data class Link(val title: String?, val url: String) : BackStackItem
    }
}